/** Simple RMI client program:

   The client program
      - import java.rmi for using Naming's static methods to create remote
	server object, and access RMI related exceptions.
      - The remote object's name in client code is the name of registered name
	of remote object that is not necessarily the same name as server's class
	name.
*/
import java.rmi.*;

public class SimpleClient1 {

   public static void main( String arg[] ) {
	if ( arg.length < 2 ) {
		System.out.println("Usage: java SimpleClient1 hostname:3941 anyString");
		System.exit(-1);
	}

	try {
		// The remote object on client side has the name registered in server
		// rmiregistry. Not the class name used in implementation of server code while
		// The registered remote object's name could be the same of server class name.
		SimpleServer1 rmiObj = (SimpleServer1) Naming.lookup("//" + arg[0].trim() +
					"/SimpleServer1");
		String msg	= "...";

		while ( ! msg.equals("") ) {
			msg = ScreenIO.promptForString("Enter a message: ");
			rmiObj.write(arg[1], msg);
		}
	} catch (Exception e) { e.printStackTrace(); }
   }
}
